﻿angular.module("umbraco").controller("UE.DeleteModalController",
    function ($scope, dealerResource, notificationsService) {
        var vm = this;
        vm.confirm = true;
        var id = $scope.$parent.dialogData;

        dealerResource.get(id).then(function (response) {
            vm.StoreName = response.StoreName;
        });

        $scope.performDelete = function () {
            dealerResource.delete("dealer_" + id).then(function (response) {
                if (response.ErrorCode == 0) {
                    $scope.submit(true);
                } else {
                    notificationsService.error("Delete Failed", "Delete failed, please try again!");
                }
            });
        }

        $scope.cancel = function () {
            $scope.submit(false);
            UmbClientMgr.closeModalWindow();
        }
    }
);